package api

import (
	"goadmin/utils"

	"github.com/gin-gonic/gin"
)

type _captchaResBody struct {
	CaptchaId string `json:"captchaId"`
	Captcha   string `json:"captcha"`
}

// @Tags captcha
// @Summary Captcha generation
// @Produce json
// @Success 200 {object} resBody{data=_captchaResBody}
// @Router /api/captchas [get]
func CaptchaGet(c *gin.Context) {
	id, b64s, err := utils.GenerateCapcha()
	if err != nil {
		resFai(c, "Failed to generate captcha")
		return
	}
	resSuc(c, _captchaResBody{
		CaptchaId: id,
		Captcha:   b64s,
	})
}
